s = [i for i in input("Введите скобочную последовательность ") if i in "()[]{}<>"]
stack = []
tf = True
if len(s) % 2 == 0:
    for i in s:
        if i in [g for g in "([{<"]:
            stack.append(i)
        else:
            if ((not len(stack)) or (i == ")" and stack[-1] != "(") or (i == "]" and stack[-1] != "[") or (
                    i == "}" and stack[-1] != "{") or (i == ">" and stack[-1] != "<")):
                print("False")
                tf = False
                break
            stack.pop()
    if tf and len(stack) == 0:
        print("True")
else:
    print("False")